﻿using Dapper;
using System.Data.SqlClient;
using yunbo.Model.BIP;

namespace yunbo.Repositorys.FPMRepositorys
{
    public class BD_CPWDRepository
    {
        public string data = "Data Source=121.37.93.71;Initial Catalog=FanXingMES;User ID=sa;Password=geili@2025;";
        public List<BD_CPWD> Getcpwd(string cp_code)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $"select* from bd_cpwd where cp_code='{cp_code}'";
                List<BD_CPWD> bd_cp = connection.Query<BD_CPWD>(sql).ToList(); // 使用 ToList() 获取所有菜单  
                return bd_cp;
            }
        }
        public int PostBD_CPWD(BD_CPWD bD_CPWD)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $"insert into [dbo].[bd_cpwd]([cpwd_code],[cpwd_name],[cpwd_lb],[cp_code]) values('{bD_CPWD.cpwd_code}','{bD_CPWD.cpwd_name}','{bD_CPWD.cpwd_lb}','{bD_CPWD.cp_code}')";
                int rs = connection.Execute(sql);
                return rs;

            }
        }
    }
}
